<template>
  <div class="app-container " style="">
    <div style="">
      <el-form ref="form" size="small" :model="form" :rules="rules" label-width="120px" style="background: rgb(255, 255, 255);width: 550px;margin: 0px 0px 0px 500px;border-radius: 10px;">
        <el-tabs v-model="activeName">
          <el-tab-pane style="padding-top:10px" label="" name="佣金设置">
            <el-row>
              <el-col :span="24">
                <el-form-item label="分销佣金类型">
                  <el-radio-group v-model="form.price_type">
                    <el-radio label="0">百分比</el-radio>
                    <el-radio label="1">固定金额</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="一层佣金%">
                  <el-input
                    v-model="form.first"
                    style="width:100px;"
                    auto-complete="off"
                    clearable
                    placeholder="请输入一层佣金"
                  >
                 <!--  <template v-if="form.price_type==0" slot="append">%</template>
                    <template v-if="form.price_type==1" slot="append">元</template> -->
                  </el-input>
                  <div class="help-block">注：一层为顾客的直接上级<br>（如果开启分销内购,分销商自己购买商品，享受一层佣金）</div>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="二层佣金%">
                  <el-input
                    v-model="form.second"
                    style="width:100px;"
                    auto-complete="off"
                    clearable
                    placeholder="请输入二层佣金"
                  >
                  <!--  <template v-if="form.price_type==0" slot="append">%</template>
                    <template v-if="form.price_type==1" slot="append">元</template> -->
                  </el-input>
                  <div class="help-block">注：二层为顾客的上上级</div>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="三层佣金%">
                  <el-input
                    v-model="form.third"
                    style="width:100px;"
                    auto-complete="off"
                    clearable
                    placeholder="请输入三层佣金"
                  >
                   <!-- <template v-if="form.price_type==0" slot="append">%</template>
                    <template v-if="form.price_type==1" slot="append">元</template> -->
                  </el-input>
                  <div class="help-block">注：三层为顾客的上上上级</div>
                </el-form-item>
              </el-col>
            </el-row>
          </el-tab-pane>
        </el-tabs>
        <el-form-item>
          <el-button size="small" type="primary" @click="submit">保存设置</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
export default {
  name: 'Configshare',
  components: {},
  data() {
    return {
      form: {
      },
      loading: false,
      activeName: '佣金设置',
      rules: {}
    }
  },
  mounted() {
    this.$api.post('/config/getInfo', {
      mo: 'share'
    }).then(res => {
      this.form = JSON.stringify(res.data) == '[]' ? {} : res.data
      this.setDefaultVal('keyword')
    })
  },
  methods: {
    submit() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          this.loading = true
          this.$api.post('/config/update', this.form).then(res => {
            this.$message({
              message: '操作成功',
              type: 'success'
            })
          }).catch(() => {
            this.loading = false
          })
        }
      })
    },
    setDefaultVal(key) {
      if (this.form[key] == null || this.form[key] == '') {
        this.form[key] = []
      }
    }
  }
}
</script>



<style lang="scss" scoped>
::v-deep .el-tabs__nav-wrap::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 0px;
    background-color: #fff;
    z-index: 1;
}


::v-deep .el-tabs__header {
    padding-left: 20px;
    height: 0px;
}
</style>